package com.cloud.drore.eboss.locker.interceptor;

import java.util.Random;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/4/16 0016 下午 6:37 <br>
 * @Author: <a href="410508961@qq.com">夏凯</a>
 */
public class StringUtils {
    public static String initcap(String name){
        if(name==null || name.equals("")){
            return name;
        }
        return name.substring(0,1).toUpperCase()+name.substring(1);
    }
    public static Object getValues(String simplename,String value){
        if("int".equalsIgnoreCase(simplename) || "Integer".equalsIgnoreCase(simplename)){
            return Integer.parseInt(value);
        }
        if("double".equalsIgnoreCase(simplename)){
            return Double.parseDouble(value);
        }
        if("float".equalsIgnoreCase(simplename)){
            return Float.parseFloat(value);
        }
        if("string".equalsIgnoreCase(simplename)){
            return value;
        }
        if("boolean".equalsIgnoreCase(simplename)){
            return Boolean.parseBoolean(value);
        }
        if("long".equalsIgnoreCase(simplename)){
            return Long.parseLong("90");
        }
        return null;
    }
    public static Object getValues(String simplename){
        Random random = new Random();
        if ("int".equalsIgnoreCase(simplename) || "Integer".equalsIgnoreCase(simplename)) {
            return  123+ random.nextInt(20);
        }
        if ("double".equalsIgnoreCase(simplename)) {
            return  12.89+ random.nextInt(20);
        }
        if ("float".equalsIgnoreCase(simplename)) {
            return  11+ random.nextInt(20);
        }
        if ("string".equalsIgnoreCase(simplename)) {
            return  "abcd"+ random.nextInt(20);
        }
        if ("boolean".equalsIgnoreCase(simplename)) {
            return  false;
        }
        if("long".equalsIgnoreCase(simplename)){
            return  Long.parseLong("90"+ random.nextInt(20));
        }
        return null;
    }
}
